package com.dcm.seckill;


import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;


/**
 * @author 牛浩
 */
@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
@ComponentScan(basePackages = {"com.dcm.seckill","com.dcm.common"})
public class DcmSeckillApplication {
    public static void main(String[] args) {
        SpringApplication.run(DcmSeckillApplication.class,args);
    }

    /**
     * 声明一个队列
     * @return
     */
    @Bean
    public Queue queue01(){
        return new Queue("seckillQ",false,false,false,null);
    }

    /**
     * 声明交换机
     * @return
     */
    @Bean
    public DirectExchange ex01(){
        return new DirectExchange("seckillEX");
    }

    /**
     * 绑定关系
     * @return
     */
    @Bean
    public Binding bind01(){
        return BindingBuilder.bind(queue01()).to(ex01()).with("seckill");
    }
}
